package com.dsz.du.mealbooking.dao;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;
import com.dsz.du.mealbooking.model.UserModel;

@Repository(value="userDao")
public class UserDaoGAEImp extends BaseDao implements UserDao {
	
	private static Logger logger = Logger.getLogger(UserDaoGAEImp.class);

	@Override
	public UserModel getUser(String userId) {
		
		if (logger.isDebugEnabled()){
			logger.debug("111222get User userId : " + userId);
		}
		
		StringBuffer query = new StringBuffer();
		query.append("select from " + UserModel.class.getName());
		query.append(" where userId == '");
		query.append(userId);
		query.append("'");
		String queryString = query.toString();
		
		if (logger.isDebugEnabled()){
			logger.debug("get User SQL : " + queryString);
		}

		UserModel user = (UserModel) super.excuteSingleQuery(queryString);
		return user;
	}
	
	@Override
	public void registerUser(UserModel userModel) {
		String userId = userModel.getUserId();
		if (logger.isDebugEnabled()){
			logger.debug("registerUser userId : " + userId);
		}
		super.saveModel(userModel);

	}	
}
